package com.rtx.wms.std.handler.so.down;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;

import com.rtx.wms.std.common.bean.WmsConstant;
import com.rtx.wms.std.so.bean.ApiOrderdetail;
import com.rtx.wms.std.so.bean.ApiOrders;
import com.rtx.wms.std.validation.so.OrdersValidation;

/**
 * 格瑞普出库单下发
 * @author Administrator
 *
 */
@Service
public class GrpSoCreateHandle extends AbstractOrdersDownHandler{
	
	@Autowired
	OrdersValidation ordersValidation;
	

	@Override
	protected void validationSpecific(ApiOrders apiOrders) {
		
	}

	@Override
	protected ApiOrders preHandle(HttpServletRequest request) {
		return null;
	}

	@Override
	protected void preinsert(ApiOrders o, HttpServletRequest request) {
		
	}

	@Override
	protected void afterHandle(ApiOrders apiOrders, String requestStr) {
			Assert.hasLength(apiOrders.getExternorderkey(),"Externorderkey 为必填!");
			Assert.hasLength(apiOrders.getRtxiscontainer(),"Rtxiscontainer为必填!");
		for(ApiOrderdetail item:apiOrders.getDetails()) {
//			Assert.hasLength(item.getRtxexternlineno2(),"rtxexternlineno2 工单行号为必填!");
			Assert.hasLength(item.getLottable01(),"Lottable01为必填!");
			Assert.hasLength(item.getLottable02(),"Lottable02为必填!");
		}
		
		ordersValidation.checkEnterpriseConfig(WmsConstant.ENTERPRISE, apiOrders);
	}
	
	
}
